// 返回fileReader 的onload promise
export function getFileReaderPromise<T>(
  operateFun: (fileReader: FileReader) => void,
): Promise<[T, ProgressEvent<FileReader>]> {
  return new Promise((resolve, reject) => {
    const fileReader = new FileReader();
    fileReader.addEventListener('load', (event) => {
      resolve([fileReader.result as T, event]);
    });
    operateFun(fileReader);
    fileReader.addEventListener('error', reject);
  });
}
